package com.zorn.platform.dictionary.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.collections.MapUtils;
import org.springframework.stereotype.Service;

import com.zorn.core.provider.ServiceSupportProvider;
import com.zorn.platform.dictionary.service.IDictionaryService;
import com.zorn.platform.dictionary.dao.DictionaryDao;

@Service
public class DictionaryService extends ServiceSupportProvider implements IDictionaryService {

	/* Fields
	================================================== */
	private DictionaryDao dictionaryDao;

	/* Methods
	================================================== */
	public List<Map<String, Object>> query(Map<String, Object> params) {
		List<Map<String, Object>> data = dictionaryDao.query(params);

		return setQueryResult(isPaging() ? dictionaryDao.count(params) : data.size(), data);
	}

	public int count(Map<String, Object> params) {
		return setCountResult(dictionaryDao.count(params));
	}

	public String insert(Map<String, Object> params) {
		return setInsertResult(dictionaryDao.insert(params), MapUtils.getString(params, "id"));
	}

	public int update(Map<String, Object> params) {
		return setUpdateResult(dictionaryDao.update(params));
	}

	public int delete(Map<String, Object> params) {
		return setDeleteResult(dictionaryDao.delete(params));
	}

	/* Getters & Setters
	================================================== */
	public void setDictionaryDao(DictionaryDao dictionaryDao) {
		this.dictionaryDao = dictionaryDao;
	}

}